import { Command } from "commander";
import { GenPluginDocCommand } from "./plugin-doc";
import consola from "consola";

export class CommandLoader {
    public static load(program: Command): void {
      new GenPluginDocCommand().load(program);
      this.handleInvalidCommand(program);
    }
  
    private static handleInvalidCommand(program: Command) {
      program.on('command:*', () => {
        consola.error(`未支持的命令: `, program.args.join(' '));
        consola.log(`请使用 --help 查看已支持的命令.\n`);
        process.exit(1);
      });
    }
  }